<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
        <script src="js/vuex.js"></script>
    </head>
    <body>
        <div id="app">
            <button @click="mut">使用mutations接收参数</button>
            <button @click="act">使用actions接收参数</button>
        </div>
        <script>
            const store = new Vuex.Store({
                state : {
                    name:'张三',
                    age: 38,
                    gender : '男'
                },
                mutations : {
                    test(state,param) {
                        console.log(state,param);
                    }
                },
                actions : {
                    test(context,param) {
                        console.log(context,param.name)
                    }
                }
            })

            var vm = new Vue({
                el:'#app',
                store,
                methods : {
                    mut(){
                        this.$store.commit('test','这里是传递的参数2')
                    },
                    act(){
                        // this.$store.dispatch('test','这里是传递的参数')
                        this.$store.dispatch({type:'test',name:'我是传递的参数'})
                    }
                }
            })
        </script>
    </body>
</html>